{% extends "base.html" %}

{% block content %}
    <h2>最新帖子</h2>

    {% for post in posts %}
        <div class="post">
            <div class="post-header">
                <h3>{{ post.title }}</h3>
                <div class="post-actions">
                    {% if session.user_id == post.user_id %}
                        <a href="{{ url_for('edit_post', post_id=post.id) }}">编辑</a>
                        <form action="{{ url_for('delete_post', post_id=post.id) }}" method="POST">
                            <button type="submit">删除</button>
                        </form>
                    {% endif %}
                </div>
            </div>
            <p>{{ post.content }}</p>
            <p>作者: {{ post.username}}</p>
        </div>
    {% endfor %}
{% endblock %}


